package org.wanho.rent.service.impl;

import org.wanho.rent.dao.SysuserDao;
import org.wanho.rent.entity.SysUser;
import org.wanho.rent.exception.LoginException;
import org.wanho.rent.factory.ObjectFactory;
import org.wanho.rent.service.SysuserService;

public class SysuserServiceImpl implements SysuserService{
	
	private SysuserDao sysuserDao = (SysuserDao) ObjectFactory.getObject("sysuserDao");

	@Override
	public SysUser login(String loginname, String loginpassword) throws LoginException {
		SysUser user = sysuserDao.selectByLoginname(loginname);
		if(user == null){
			throw new LoginException("用户名不存在！");
		}
		if(! user.getLoginPassWord().equals(loginpassword)){
			throw new LoginException("密码不正确！");
		}
		return user;
	}

}
